package py.ucom.sistemas.web.entradaspy.db.componenentes;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import py.ucom.sistemas.web.entradaspy.db.Conexion;

public class ConsultasDB {
	private Conexion puenteConexion;
	private Connection conn;
	private java.sql.Statement stm;
	private ArrayList<Evento> eventos;
	private String queryGetEventosOrdenadosAscendente = "select descripcion,link from evento order by orden asc";
	public ConsultasDB(){
		puenteConexion = new Conexion();
		conn = puenteConexion.getConnection();
		try {
			stm = conn.createStatement();
		} catch (SQLException e) {
			System.out.println(e.getMessage());
		}
	}
		
		public ArrayList<Evento> getEventos(){
			try {
				ResultSet rs = stm.executeQuery(queryGetEventosOrdenadosAscendente);
				eventos = new ArrayList<Evento>();
				while(rs.next()){
				Evento evento = new Evento();
				evento.descripcion = rs.getString("descripcion");
				evento.link = rs.getString("link");
				System.out.println(evento.descripcion);
				}
				} catch (SQLException e) {
			System.out.println("El error es "+ e.getMessage());
			}
			return eventos;
		}
		
		public static void main(String[] args) {
			ConsultasDB c=new ConsultasDB();
			c.getEventos();
		}
		
	}
	
